import dva from 'dva';
import './index.css';
import './mongolian.css';
import 'antd/dist/antd.css';  // or 'antd/dist/antd.less'
import createHistory from 'history/createBrowserHistory';
import createLoading from 'dva-loading';

//简易 观察者模式， 发布订阅
window.PubSub = (function() {  
  var eventObj = {};
  return {
      subscribe: function(event, fn) {
          eventObj[event] = fn;
      },
      publish: function(event,data) {
          if (eventObj[event]) eventObj[event](data);
      },
      off: function(event) {
          if (eventObj[event]) delete eventObj[event];
      }
  }
}());


// 1. Initialize
const app = dva({});

// 2. Plugins
app.use({});
app.use(createLoading());

// 3. Model
app.model(require('./models/example').default);
app.model(require('./models/video').default);
app.model(require('./models/theme').default);
app.model(require('./models/add').default);
app.model(require('./models/comment').default);
app.model(require('./models/themecomment').default);
app.model(require('./models/type').default);

// 4. Router
app.router(require('./router').default);

// 5. Start
app.start('#root');
